package edu.wpi.first.wpilibj.templates;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

import edu.wpi.first.wpilibj.Relay;
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.DigitalInput; 
        
/**
 *
 * @author Eric/Dean
 */


public class BallCollector 
{
    Relay collectorwheels;    
    
    Joystick xbox;
    
    PneumaticDemo armextender;
    
    DigitalInput collectorarmswitch;
    
    static boolean button = false, toggled = true;
    
    public BallCollector(int wheelrelayport, int digport,int compressorrelayport,int sole1,int sole2, int limitswitch)
    {
        collectorwheels = new Relay (wheelrelayport);
        
        xbox = new Joystick (3);
       
        armextender = new PneumaticDemo (digport, compressorrelayport, sole1, sole2);
        
        collectorarmswitch = new DigitalInput (limitswitch);
    }
    
    void collect(){
        collectorwheels.set(Relay.Value.kForward);
if (collectorarmswitch.get()){
    
        collectorwheels.set(Relay.Value.kOff);
}
    }
            
    void release(){
        collectorwheels.set(Relay.Value.kReverse);
    }    
            
    void putinlauncher(){
        collectorwheels.set(Relay.Value.kForward);
    }
    
    void run (){        
    
if (collectorarmswitch.get()){
    
    putinlauncher();}

else if (collectorwheels.get()==Relay.Value.kReverse || collectorwheels.get()==Relay.Value.kForward){

    collectorwheels.set (Relay.Value.kOff);
}
else {
    collect();
}

    
if (xbox.getRawButton(XBox.RB)){    
    
    release();
    
    }
    
}

public void ballcollectortogglebutton(){
if (xbox.getRawButton(XBox.LB)&&!toggled){
    toggled = true;
    run();

}

else if (!xbox.getRawButton (XBox.LB)){
    toggled = false;
}
}

}